home *** CD-ROM | disk | FTP | other *** search
/ Aminet 20 / Aminet 20 (1997)(GTI - Schatztruhe)[!][Aug 1997].iso / Aminet / dev / src / TDRenderLib.lha / tdrenderlib / ReadMe.Library < prev    next >
Text File  |  1997-06-22  |  11KB  |  350 lines

  1.  
  2. -----------------------
  3. TD Render Lib V1.0 Beta 
  4. -----------------------
  5.     FreeWare Lib
  6. -----------------------
  7.  By Yves ROSSO - 1997
  8. -----------------------
  9.  
  10. First, i'm not a great coder :(, i've understood the basis of asm 
  11. and E programming but i've no more time to learn all about mem
  12. pointers using in asm ... So, i went to aminet to up load this 
  13. sources of code and base bin, to give it to amiga users who are
  14. interested in continue development.
  15.  
  16. The library need more shape drawing routines, effects routines,
  17. better stars drawing, a better filling routine (mine is a trick,
  18. no bug but not clean), ect ... Resolution adaptative :) ...
  19. and certainly angles/vectors calc errors ;).
  20.  
  21.  
  22. Purpose :   Making a 3D realtime graphic library that's independant
  23. --------    from the hardware. By buffering all 3D faces tracing in 
  24.             a fastmem buffer transfered on a double-buffered screen.
  25.             
  26. Sources :   In E :
  27. --------    -----
  28.             For controlling the Asm Library.
  29.             My E source isn't a lot documented, you will find
  30.             an example of double-buffered screen use in cgfx
  31.             mode.
  32.             
  33.             You can use any language you want i think, if it 
  34.             can call asm routines from lib.
  35.  
  36.             In Asm :
  37.             -------
  38.             3D rendering part
  39.             I think my asm source is enough documented to
  40.             explain what's done in it.
  41.             For instance the lib use a 32bit xRGB buffer for
  42.             drawing ( 320x240x32 provided by the E prog or
  43.             yours, RaceCar or Space Simulation :).
  44.             
  45. Lib Functions :
  46. --------------
  47.  
  48. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  49. ; tdClearFrmBuf(a0)
  50. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  51. ;       BufferAddress in A0  (*) 320x240 buffer 
  52. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  53.  
  54. tdClearFrmBuf(bufferaddress)(a0)
  55.  
  56.  = Clear the 32bit buffer to 0
  57.             
  58.  
  59.  
  60.  
  61. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  62. ; tdClearFrmBufCol(a0,d0)
  63. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  64. ;       BufferAddress in A0  (*) 320x240 buffer
  65. ;               Color in D0  xRGB 32bit color
  66. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  67.  
  68. tdClearFrmBufCol(bufferaddress,color)(a0,d0)
  69.  
  70.  = Clear the 32bit buffer to a specified 32bit color
  71.  
  72.  
  73.  
  74.  
  75. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  76. ; D0 = tdRgbToVal(d0,d1,d2)
  77. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  78. ;           Red Color in D0  
  79. ;         Green Color in D1
  80. ;          Blue Color in D2
  81. ;
  82. ; return xRGB32 Color in D0 
  83. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  84. tdRgbToVal(r,g,b)(d0/d1/d2)
  85.  
  86.  = Convert an R=8bit,G=8bit,B=8bit color to xRGB=32bit color
  87.  
  88.  
  89.  
  90.  
  91. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  92. ; D0,D1,D2 = tdPixelColRgb(a0,d0,d1)
  93. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  94. ;       BufferAddress in A0 
  95. ;        x coordinate in D0
  96. ;        y coordinate in D1
  97. ;
  98. ; return    Red Color in D0  
  99. ;         Green Color in D1
  100. ;          Blue Color in D2
  101. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  102. tdPixelColRgb(bufferaddress,x,y)(a0,d0/d1)
  103.  
  104.  = Get color of point in 32bit buffer in R,G,B format
  105.  
  106.  
  107.  
  108.  
  109. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  110. ; D0 = tdPixelColVal(a0,d0,d1)
  111. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  112. ;       BufferAddress in A0 
  113. ;        x coordinate in D0
  114. ;        y coordinate in D1
  115. ;
  116. ; return xRGB32 Color in D0 
  117. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  118. tdPixelColVal(bufferaddress,x,y)(a0,d0/d1)
  119.  
  120.  = Get color of point in 32bit buffer in xRGB format
  121.  
  122.  
  123.  
  124.  
  125.  
  126. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  127. ; tdPixel(a0,d0,d1,d2)       
  128. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  129. ;       BufferAddress in A0 
  130. ;        X Coordinate in d0
  131. ;        Y Coordinate in d1
  132. ;               Color in d2
  133. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  134. tdPixel(bufferadress,x,y,color)(a0,d0/d1/d2)
  135.  
  136.  = Draw a pixel in the 32bit buffer with specified color
  137.  
  138.  
  139.  
  140.  
  141. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  142. ; tdLine(a0,d0,d1,d2,d3,d4)       
  143. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  144. ;       BufferAddress in A0 
  145. ;       Xo Coordinate in d0
  146. ;       Yo Coordinate in d1
  147. ;       Xe Coordinate in d2
  148. ;       Ye Coordinate in d3
  149. ;               Color in d4
  150. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  151. tdLine(bufferaddress,xo,yo,xe,ye,color)(a0,d0/d1/d2/d3/d4)
  152.  
  153.  = Draw a line in the 32bit buffer with specified color
  154.  
  155.  
  156.  
  157.  
  158. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  159. ; tdBox(a0,d0,d1,d2,d3,d4)       
  160. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  161. ;       BufferAddress in A0 
  162. ;       Xo Coordinate in d0
  163. ;       Yo Coordinate in d1
  164. ;       Xe Coordinate in d2
  165. ;       Ye Coordinate in d3
  166. ;               Color in d4
  167. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  168. tdBox(bufferaddress,xo,yo,xe,ye,color)(a0,d0/d1/d2/d3/d4)
  169.  
  170.  = Draw a box in the 32bit buffer with specified color
  171.  
  172.  
  173.  
  174.  
  175. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  176. ; tdBoxFill(a0,d0,d1,d2,d3,d4)       
  177. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  178. ;       BufferAddress in A0 
  179. ;       Xo Coordinate in d0
  180. ;       Yo Coordinate in d1
  181. ;       Xe Coordinate in d2
  182. ;       Ye Coordinate in d3
  183. ;               Color in d4
  184. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  185. tdBoxFill(bufferaddress,xo,yo,xe,ye,color)(a0,d0/d1/d2/d3/d4)
  186.  
  187.  = Draw a filled box in the 32bit buffer
  188.  
  189.  
  190.  
  191.  
  192. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  193. ; tdDrawStars(a0,a1,d0,d1)       
  194. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  195. ;      Render Buffer Address in A0 
  196. ;       Stars Buffer Address in A1
  197. ;               Stars Number in D0
  198. ;                  Draw Mode in D1 ( 0 - normal
  199. ;                                  ( 1 - flashing not really working ;(
  200. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  201. tdDrawStars(bufferaddress,starbufferaddress,nbstars,mode)(a0/a1,d0/d1)
  202.  
  203.  = Draw 2D stars in 32bit buffer, you must provide a stars table
  204.    in your soft.
  205.    
  206.  
  207.  
  208.  
  209. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  210. ; tdMovRotStars(a0,d0,d1,d2,d3,d4,d5)       
  211. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  212. ;       Stars Buffer Address in A0 
  213. ;              X Translation in D0
  214. ;              Y Translation in D1
  215. ;          X Rotation Center in D2
  216. ;          Y Rotation Center in D3  
  217. ;          Angle Of Rotation in D4 (degree value)
  218. ;               Stars Number in D5
  219. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  220. tdMovRotStars(bufferaddress,transx,transy,centx,centy,angle,nbstars)(a0,d0/d1/d2/d3/d4/d5)
  221.  
  222.  = This modify 2D stars coords in stars table.
  223.  
  224.  
  225.  
  226.  
  227. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  228. ; tdSetLight(d0,d1,d2,d3,d4,d5)       
  229. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  230. ;      Light Xo position in D0 (integer) \
  231. ;            Yo position in D1 (integer)  |
  232. ;            Zo position in D2 (integer) /
  233. ;            -----------------------------> 2 pts to define a vector
  234. ;            Xe position in D3 (integer) \
  235. ;            Ye position in D4 (integer)  |
  236. ;            Ze position in D5 (integer) /
  237. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  238. tdSetLight(xpos,ypos,zpos,xpos,ypos,zpos)(d0/d1/d2/d3/d4/d5)
  239.  
  240.  = Set the light position and direction in 3D space.
  241.  
  242.  
  243.  
  244.  
  245. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  246. ; tdSetCamera(d0,d1,d2,d3,d4,d5)       
  247. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  248. ;           Camera X position in D0 (integer)
  249. ;                  Y position in D1 (integer)
  250. ;                  Z position in D2 (integer)
  251. ;                    an Angle in D3 (degree value) 
  252. ;                    bn Angle in D4 (degree value)
  253. ;                    cn Angle in D5 (degree value) 
  254. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  255. tdSetCamera(xpos,ypos,zpos,anglea,angleb,anglec)(d0/d1/d2/d3/d4/d5)
  256.  
  257.  = Set camera position and direction in 3D 
  258.  
  259.  
  260.  
  261.  
  262.  
  263. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  264. ; tdGetMatrix(d0,d1,d2)
  265. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  266. ;                    an Angle in D0 (degree value) 
  267. ;                    bn Angle in D1 (degree value)
  268. ;                    cn Angle in D2 (degree value) 
  269. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  270. tdGetMatrix(anglea,angleb,anglec)(d0/d1/d2)
  271.  
  272.  = Calc a matrix with value given and store it in internal
  273.    lib table. ( internally used by lib, but can be used
  274.    also by extern call ) Look at the ASM source.
  275.    
  276.  
  277.  
  278. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  279. ; tdRotCoord(d0,d1,d2)
  280. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  281. ;                  X position in D0 (integer)
  282. ;                  Y position in D1 (integer)
  283. ;                  Z position in D2 (integer)
  284. ;
  285. ; Return Xrot,Yrot,Zrot in D0,D1,D2
  286. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  287. tdRotCoord(xpos,ypos,zpos)(d0/d1/d2)
  288.  
  289.  = Calculated new X,Y,Z point position from matrix calculated
  290.    with < tdGetMatrix > , the function don't trash matrix table.
  291.    
  292.  
  293.  
  294.  
  295. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  296. ; tdDrwObFrmCam(a0,a1,d0,d1,d2,d3,d4,d5)       
  297. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  298. ;        Frame Buffer Address in A0 
  299. ; Object Faces Buffer Address in A1 
  300. ;           Object X position in D0 (integer)
  301. ;                  Y position in D1 (integer)
  302. ;                  Z position in D2 (integer)
  303. ;                    an Angle in D3 (degree value) 
  304. ;                    bn Angle in D4 (degree value)
  305. ;                    cn Angle in D5 (degree value) 
  306. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  307. tdDrwObFrmCam(bufferaddress,objectbuffer,xpos,ypos,zpos,anglea,angleb,anglec)(a0,a1,d0/d1/d2/d3/d4/d5)
  308.  
  309.  = Draw specified 3D object at a specified position and direction
  310.    in function of the position and direction of the camera.
  311.    
  312.    ( Not really tested with camera movements for instance
  313.    the E source have a fixed position camera with rotations free )
  314.  
  315.  
  316.  
  317.  
  318. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  319. ; tdDrawObject(a0,a1,d0,d1,d2,d3,d4,d5)       
  320. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  321. ;        Frame Buffer Address in A0 
  322. ; Object Faces Buffer Address in A1 
  323. ;           Object X position in D0 (integer)
  324. ;                  Y position in D1 (integer)
  325. ;                  Z position in D2 (integer)
  326. ;                    an Angle in D3 (degree value) 
  327. ;                    bn Angle in D4 (degree value)
  328. ;                    cn Angle in D5 (degree value) 
  329. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  330. tdDrawObject(bufferaddress,objectbuffer,xpos,ypos,zpos,anglea,angleb,anglec)(a0,a1,d0/d1/d2/d3/d4/d5)
  331.  
  332.  = Draw specified 3D object at a specified position and direction,
  333.    do not use camera settings, the camera is fixed to 0 pos and dir.
  334.    ( For testing object )
  335.  
  336.  
  337.  
  338. ============================================================
  339.  _________
  340. | _    _  |
  341. |( )| (_) |
  342. | (_|____ |
  343. |  _|____ |
  344. |   |     |
  345. |  _____  |
  346. |_________|
  347.  
  348. 22/06/97,   Yves ROSSO
  349.             rosso@avo.net
  350.             http://www.accueil.com/rosso/